/**
 * Created with IntelliJ IDEA.
 * Description: 判断是不是二叉搜索树
 * User: wangxin
 * Date: 2024-11-09
 * Time: 22:03
 */

import java.util.*;


   class TreeNode {
    int val = 0;
    TreeNode left = null;
    TreeNode right = null;
    public TreeNode(int val) {
      this.val = val;
    }
  }

public class test1 {
    public boolean isCompleteTree (TreeNode root) {
        // write code here
        if(root == null){
            return true;
        }
        Queue<TreeNode> q = new LinkedList<>();
        q.offer(root);
        TreeNode cur;
        boolean notC = false;
        while(!q.isEmpty()){
            cur = q.poll();
            if(cur == null){
                notC = true;
                continue;
            }
            if(notC){
                return false;
            }
            q.offer(cur.left);
            q.offer(cur.right);
        }
        return true;
    }
}
